<%@ page contentType="text/html;charset=UTF-8"%>
<html>
  <head>
    <title>动态设置页面的MIME类型</title>
  </head> 
  <body>
    <h2>学生成绩表</h2>
    <table border="1">
    	<tr>
    		<th>学号</th>
    		<th>姓名</th>
    		<th>成绩</th>
    	</tr>
    	<tr>
    		<td>20210101</td>
    		<td>蓝天</td>
    		<td>98</td>
    	</tr>
    	<tr>
    		<td>20210102</td>
    		<td>白云</td>
    		<td>96</td>
    	</tr>
    	<tr>
    		<td>20210103</td>
    		<td>高原</td>
    		<td>88</td>
    	</tr>
    	<tr>
    		<td>20210104</td>
    		<td>田野</td>
    		<td>90</td>
    	</tr>
    </table>
    <p>选择以下类型打开或保存页面</p>
    <form action="" method="post">
    	<input type="radio" name="filetype" value="w">Word
    	<input type="radio" name="filetype" value="e">Excel<br>
    	<input type="submit" name="submit" value="提交">
    </form>
    
    <%
    	String str=request.getParameter("filetype");
    	if(str==null){
    		str="";
    	}else if(str.equals('w')){
    		response.setContentType("application/msword;charset=utf-8");
    	}else if(str.equals('e')){
    		response.setContentType("application/x-msexcel;charset=utf-8");
    	}
     %>
  </body>
</html>
